#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1e6 + 5;
const int P = 131;
using ull = unsigned long long;

int n, m;
string s;
ull f[N], g[N];
ull base[N];
int get() {
  base[0] = 1;
  rep(i, 1, n) base[i] = base[i - 1] * P;
  rep(i, 1, n) f[i] = f[i - 1] * P + s[i - 1];
  per(i, n, 1) g[i] = g[i + 1] * P + s[i - 1];
  int ans = 0;
  rep(i, 1, n) {
    // i 为中心
    int l = 1, r = min(i, n + 1 - i);
    while (l <= r) {
      int mid = l + r >> 1;
      int j = i + 1 - mid, k = i + mid - 1;
      ull x = f[i] - f[j - 1] * base[mid];
      ull y = g[i] - g[k + 1] * base[mid];
      if (x == y)
        l = mid + 1;
      else
        r = mid - 1;
    }
    ans = max(ans, r * 2 - 1);
    // i, i + 1 为中心
    l = 1, r = min(i, n - i);
    while (l <= r) {
      int mid = l + r >> 1;
      int j = i + 1 - mid, k = i + mid;
      ull x = f[i] - f[j - 1] * base[mid];
      ull y = g[i + 1] - g[k + 1] * base[mid];
      if (x == y)
        l = mid + 1;
      else
        r = mid - 1;
    }
    ans = max(ans, r * 2);
  }
  return ans;
}
void solve() {
  static int id = 0;
  id++;
  cout << "Case " << id << ": ";
  n = s.size();
  cout << get() << endl;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  while ((cin >> s) && s != "END") solve();
  return 0;
}